home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / infosrvr / dev / libhtml_.tar / SGML.h < prev   
C/C++ Source or Header  |  1993-01-20  |  6KB  |  182 lines

  1. /* SGML.h
  2.  * $Id: SGMLstream.h,v 1.3 93/01/06 18:40:29 connolly Exp Locker: connolly $
  3.  */
  4.  
  5. #ifndef SGML_h
  6. #define SGML_h
  7.  
  8. #include "c_dialect.h"
  9. #include "HMDoc.h"
  10.  
  11. /*
  12.  * supported variations on the SGML declaration
  13.  */
  14.  
  15. #ifdef SGML_DECLARATION
  16. #include SGML_DECLARATION
  17. #endif
  18.  
  19. #ifndef SGML_NAMELEN
  20. #define SGML_NAMELEN 8
  21. #endif
  22.  
  23. #ifndef SGML_LITLEN
  24. #define SGML_LITLEN 240
  25. #endif
  26.  
  27. #ifndef SGML_ATTCNT
  28. #define SGML_ATTCNT 40
  29. #endif
  30.  
  31. #ifndef SGML_TAGLVL
  32. #define SGML_TAGLVL 24
  33. #endif
  34.  
  35. #ifndef SGML_SHORTTAG
  36. #define SGML_SHORTTAG 1
  37. #endif
  38.  
  39. #ifndef SGML_UCNMCHAR
  40. #define SGML_UCNMCHAR ".-"
  41. #endif
  42.  
  43. /*
  44.  * SGML content types
  45.  */
  46.  
  47. enum {
  48.   SGML_EMPTY,    /* no content */
  49.   SGML_CDATA,    /* character data. recognize </ only */
  50.   SGML_RCDATA,   /* replaceable character data. recognize </ and &ref; */
  51.   SGML_MIXED,    /* elements and parsed character data. recognize all markup */
  52.   SGML_ELEMENT   /* any data found will be returned as an error*/
  53.   };
  54.  
  55. #ifndef EOF
  56. #define EOF (-1)
  57. #endif
  58.  
  59. enum {
  60.   SGML_record_end = -5,
  61.   SGML_entity = -4,
  62.   SGML_start_tag = -3,
  63.   SGML_end_tag = -2,
  64.   /* EOF = -1, */
  65.   SGML_error = 0
  66.   };
  67.  
  68.  
  69. VOID
  70.   SGML_parseInstance PARAMS((HMStream stream, HMGetcProc getc,
  71.                  HMDoc* document,
  72.                  CONST HMDoc_Class *docclass));
  73. /* documentation @@
  74.  */
  75.  
  76. int
  77.   SGML_read PARAMS((HMStream stream,
  78.             HMGetcProc getc,
  79.             char* buf, int nbytes,
  80.             int content,
  81.             int* inout_lookahead));
  82. /* 
  83.  * PRE:
  84.  * stream -- opaque stream object
  85.  * getc -- getc method for stream. returns -1 on EOF
  86.  * buf -- where to store data
  87.  * nbytes -- how much to read MUST BE > 3!
  88.  * entities -- opaque entities object
  89.  * expand_entity -- method for entities
  90.  *    (expand_entity)(entities, name, dest)
  91.  *    stores the expansion of name at dest, and returns the length
  92.  * max_entity_length -- upper bound on return value of expand_entity
  93.  * content -- SGML_CDATA, SGML_RCDATA, SGML_MIXED, or SGML_ELEMENT
  94.  * inout_lookahead -- EOF or first character of input
  95.  *
  96.  * POST:
  97.  * returns value:
  98.  * @@ record_end
  99.  *   SGML_start_tag ==> sgml start tag found. *inout_lookahead
  100.  *                      is first character of name. rest of name
  101.  *                      follows on stream.
  102.  *   SGML_end_tag   ==> sgml end tag found, like start tag
  103.  *                  NOTE: SGML_read attempts to discard newlines
  104.  *                        between tags: if *inout_lookahead == EOF, newlines
  105.  *                        before tags and markup declarations
  106.  *                        will be discarded.
  107.  *                        There is a pathological case where
  108.  *                        there are more than nbytes-4 leading newlines.
  109.  *                        In that case, the newlines will be treated as data,
  110.  *                        even though they may be between tags.
  111.  *   SMGL_entity    ==> entity reference found. name is in the buffer,
  112.  *                      null terminated
  113.  *   EOF            ==> EOF found before any tags or data
  114.  *                      (note that SGML_read may skip over newlines, comments,
  115.  *                       processing insructions, and markup declarations
  116.  *                       to get to EOF)
  117.  *                      *inout_lookahead is not defined.
  118.  *   SGML_error     ==> data found in element content, or
  119.  *                      possible markup was found ('<' or '&')
  120.  *                      and nbytes was not sufficient to determine
  121.  *                      whether the character was markup or data
  122.  *                      NOTE: if nbytes > SGML_NAMELEN+1, SGML_read is
  123.  *                             guaranteed not to return 0.
  124.  *                      *inout_lookahead is set to the last value
  125.  *                       read from stream.
  126.  *   0<ret<nbytes   ==> ret bytes of data found, followed by
  127.  *                      '<', which may begin a tag, or
  128.  *                      '&' with insufficient room to determine
  129.  *                          whether it's data, or insufficient
  130.  *                          room for the name of the entity.
  131.  *   nbytes         ==> nbytes of data found.
  132.  *                      *inout_lookahead = EOF (ready for next call)
  133.  */
  134.  
  135.  
  136. int
  137.   SGML_read_name PARAMS((HMStream stream,
  138.              HMGetcProc getc,
  139.              char* buf,
  140.              int* inout_lookahead));
  141. /* 
  142.  * PRE:
  143.  * stream -- opaque stream object
  144.  * getc -- getc method for stream. returns -1 on EOF
  145.  * buf -- where to store name (must be at least SGML_NAMELEN chars)
  146.  * inout_lookahead -- EOF or first character of input
  147.  *
  148.  * POST:
  149.  * returns value:
  150.  *   0              ==> first character is not a name.
  151.  *   0<ret<=SGML_NAMELEN
  152.  *                  ==> name is ret bytes long
  153.  *                      folded to lower case and stored at buf.
  154.  *                      trailing whitespace is skipped
  155.  *                      *inout_lookahead = last value read from stream
  156.  */
  157.  
  158.  
  159. int
  160.   SGML_read_value PARAMS((HMStream stream,
  161.               HMGetcProc getc,
  162.               char* buf,
  163.               int* inout_lookahead));
  164. /*
  165.  * PRE:
  166.  * stream -- opaque stream object
  167.  * getc -- getc method for stream. returns -1 on EOF
  168.  * buf -- where to store value (must be at least SGML_LITLEN chars)
  169.  * inout_lookahead -- EOF or first character of input
  170.  *
  171.  * POST:
  172.  * returns value:
  173.  *   0              ==> first character is not a letter, a digit, or a quote.
  174.  *   0<ret<=SGML_LITLEN
  175.  *                  ==> value is ret bytes long
  176.  *                      stored at buf with entities  expanded
  177.  *                      trailing whitespace is skipped
  178.  *                      *inout_lookahead = last value read from stream
  179.  */
  180.  
  181. #endif /* SGML_h */
  182.